
IF EXISTS (SELECT * FROM sysobjects WHERE name = 'SelectCursoByPeriodo' AND user_name(uid) = 'dbo')
	DROP PROCEDURE dbo.SelectCursoByPeriodo
GO

CREATE PROCEDURE dbo.SelectCursoByPeriodo 
(
  @periodo int,
  @persona int
)
AS
SELECT     Curso.nombre, 
		   Curso.codigo
FROM    DetalleMatricula INNER JOIN
        Matricula ON DetalleMatricula.cod_matricula = Matricula.codigo INNER JOIN
        Curso ON DetalleMatricula.cod_curso = Curso.codigo
WHERE 
	Matricula.cod_periodo = @periodo and
	Matricula.cod_persona = @persona

select *from usuario
select *from persona
select *from perfil
GO
--
--IF EXISTS (SELECT * FROM sysobjects WHERE name = 'InsertCommandPlan' AND user_name(uid) = 'dbo')
--	DROP PROCEDURE dbo.InsertCommandPlan
--GO
--
--CREATE PROCEDURE dbo.InsertCommandPlan
--(
--
--	@nombre nchar(100),
--	@fk_facultad int
--)
--AS
--DECLARE @ID INT
--SET @ID = (SELECT MAX(codigo) FROM [Plan])  
--                                                                                                                                                                                                            
--IF @ID IS NULL OR @ID=0                                                                                                                                                                                                                           
--	SET @ID = 1                                                                                                                                                                                                                                      
--ELSE                                                                                                                                                                                                                                                            
-- SET @ID = @ID + 1  
--	SET NOCOUNT OFF;
--INSERT INTO [Plan] ([codigo], [nombre], [fk_facultad]) VALUES (@id, @nombre, @fk_facultad)
--GO
--
--
--IF EXISTS (SELECT * FROM sysobjects WHERE name = 'UpdateCommandPlan' AND user_name(uid) = 'dbo')
--	DROP PROCEDURE dbo.UpdateCommandPlan
--GO
--
--CREATE PROCEDURE dbo.UpdateCommandPlan
--(
--	@Original_codigo int,
--	@nombre nchar(100),
--	@fk_facultad int
--)
--AS
--	SET NOCOUNT OFF;
--UPDATE [Plan] 
--	SET [nombre] = @nombre, 
--	 [fk_facultad] = @fk_facultad
--WHERE ([codigo] = @Original_codigo)
--	
--go
--
--IF EXISTS (SELECT * FROM sysobjects WHERE name = 'DeleteCommandPlan' AND user_name(uid) = 'dbo')
--	DROP PROCEDURE dbo.DeleteCommandPlan
--GO
--
--CREATE PROCEDURE dbo.DeleteCommandPlan
--(
--	@Original_codigo int
--)
--AS
--	SET NOCOUNT OFF;
--DELETE FROM [Plan] WHERE ([codigo] = @Original_codigo) 
--GO
